import time

from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver

# 1. 打开浏览器驱动管理
ChromeIns = ChromeDriverManager().install()
# 2. 创建谷歌浏览器对象
driver = webdriver.Chrome(service=Service(ChromeIns))
# 3. 输入文件上传网页
driver.get('file:///E:/Code/python/Python%E8%87%AA%E5%8A%A8%E5%8C%96/selenium/selenium-html/upload.html')
# 4. 文件上传
ele = driver.find_element(By.CSS_SELECTOR, 'body > div > div > input[type=file]')
ele.send_keys('D:\\7_zip\\7-Zip\\readme.txt')
time.sleep(1)
# 5. 退出浏览器
driver.quit()